import React from "react";
import {Button, Col, Row} from "antd";

import BaseComponent from "../../../../../../redare/components/BaseComponent";

export default class Header extends BaseComponent {

    static defaultProps = {
        title: '未知系统',
        onLoginOut: undefined
    };

    constructor(props) {
        super(props);
    }

    _onLoginOut() {
        if (this.props.onLoginOut) {
            this.props.onLoginOut();
        }
    }

    render() {
        let _workbench = window._workbench || {};
        let _user = _workbench._user || {};
        let _title = _workbench._sysName || _user.platformName || this.props.title;
        return (
            <Row>
                <Col span={23}>
                    <h2>{_title}
                        <small style={({marginLeft: 20, fontSize: 14, color: '#aaa'})}>
                            <b style={({marginRight: 10})}>用户：{_user.name}</b>
                            <b style={({marginRight: 10})}>角色：{_user.roleNames}</b>
                        </small>
                    </h2>
                </Col>
                <Col span={1}>
                    <Button type="danger" size="small" onClick={this._onLoginOut.bind(this)}>退出登录</Button>
                </Col>
            </Row>
        );
    }
}
